<!DOCTYPE html>
<html>
<head >
    <meta charset="UTF-8">
    <link href="/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="/css/font-awesome.min.css" />
    <link rel="stylesheet" href="/css/community.css" />
    <!--[if lt IE 9]>
    <script src="/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

    <div class="main-content main-contentArticle" id="contentArticle">
            <div class="row">
                <div class="col-xs-12">
                    <div class="widget wgreen">

                        <div class="widget-head">
                            <div class="pull-left">新增内容</div>
                            <div class="widget-icons pull-right">

                                <!--<a href="#" class="wclose"><i class="icon-remove"></i></a>-->
                                <button type="button" class="closer"><span >×</span></button>
                            </div>
                            <div class="clearfix"></div>
                        </div>

                        <div class="widget-content">
                            <div class="padd">



                                <!-- Form starts.  -->
                                <form class="form-horizontal" role="form" method="post" action="/category/<%=method%>">
                                    <input type="hidden" name="_id" value="<%=category._id?category._id:''%>">
                                    <div class="form-group">
                                        <label class="col-lg-4 control-label">栏目名称</label>
                                        <div class="col-lg-8">
                                            <input type="text" class="form-control" placeholder="最大长度为300" name="name" value="<%=category.name?category.name:''%>">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-4 control-label">栏目序号</label>
                                        <div class="col-lg-8">
                                            <input type="text" class="form-control" placeholder="越大越靠前" name="order_by" value="<%=category.order_by?category.order_by:''%>">
                                        </div>
                                    </div>
                                    <%if(categories && categories.length){%>
                                    <div class="form-group">
                                        <label class="col-lg-4 control-label">父栏目</label>
                                        <div class="col-lg-8">
                                            <ul class="nav nav-list">
                                                <%

                                                for(var i=0;i<categories.length;i++){
                                                    var firstCategory = categories[i];
                                                %>
                                                <li><a href="#" class="dropdown-toggle"><input type="radio" name="parent_id" value="<%=firstCategory._id%>" <%=(firstCategory._id&&category.parent_id)?(firstCategory._id.toString() == category.parent_id._id.toString()?'checked':''):''%>/> <span class="menu-text"><%= firstCategory.name%></span> <b class="arrow icon-angle-down"></b> </a>
                                                    <%
                                                    if(firstCategory.children && firstCategory.children.length){
                                                    %>
                                                    <ul class="submenu">
                                                        <%
                                                        for(var j=0;j<firstCategory.children.length;j++){
                                                            var subCategory = firstCategory.children[j];
                                                        %>
                                                        <li><a href="#"> <input type="radio" name="parent_id" value="<%=subCategory._id%>" <%=(subCategory._id&&category.parent_id)?(subCategory._id.toString() == category.parent_id._id.toString()?'checked':''):''%>/> <%=subCategory.name%></a> </li>
                                                        <%
                                                        if(subCategory.children && subCategory.children.length){
                                                        for(var m=0;m<subCategory.children.length;m++){
                                                            var thirdCategory = subCategory.children[m];
                                                        %>
                                                        <li> <a href="#"> <input type="radio" name="parent_id" value="<%=thirdCategory._id%>" <%=(thirdCategory._id&&category.parent_id)?(thirdCategory._id.toString() == category.parent_id._id.toString()?'checked':''):''%>/> <%=thirdCategory.name%></a> </li>
                                                        <%
                                                        }
                                                        }
                                                        }
                                                        %>
                                                    </ul>
                                                    <%
                                                    }
                                                    %>
                                                    <%
                                                    }

                                                    %>
                                            </ul>
                                        </div>
                                    </div>
                                    <%}%>
                                    <div class="form-group">
                                        <div class="col-lg-offset-1 col-lg-9" style="text-align: center">
                                            <button type="submit" class="btn btn-primary btn-lg" style="margin-right: 10px;">确定</button>
                                            <button type="reset" class="btn btn-primary btn-lg " >重置</button>


                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="widget-foot">
                            <!-- Footer goes here -->
                        </div>
                    </div>
                </div>

            </div>

    </div>
</body>
</html>
<script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/bootstrap-wysiwyg.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/ace.js"></script>
<script src="/js/ace-elements.min.js"></script>
<script type="text/javascript">
    jQuery(function($) {
        if($(".modal").css("display")=="block") {
            $('#editor').ace_wysiwyg({
                toolbar: [
                    {
                        name: 'font',
                        title: 'Custom tooltip',
                        values: ['Some Font!', 'Arial', 'Verdana', 'Comic Sans MS', 'Custom Font!']
                    },
                    null,
                    {
                        name: 'fontSize',
                        title: 'Custom tooltip',
                        values: {1: 'Size#1 Text', 2: 'Size#1 Text', 3: 'Size#3 Text', 4: 'Size#4 Text', 5: 'Size#5 Text'}
                    },
                    null,
                    {name: 'bold', title: 'Custom tooltip'},
                    {name: 'italic', title: 'Custom tooltip'},
                    {name: 'strikethrough', title: 'Custom tooltip'},
                    {name: 'underline', title: 'Custom tooltip'},
                    null,
                    'insertunorderedlist',
                    'insertorderedlist',
                    'outdent',
                    'indent',
                    null,
                    {name: 'justifyleft'},
                    {name: 'justifycenter'},
                    {name: 'justifyright'},
                    {name: 'justifyfull'},
                    null,
                    {
                        name: 'createLink',
                        placeholder: 'Custom PlaceHolder Text',
                        button_class: 'btn-purple',
                        button_text: 'Custom TEXT'
                    },
                    {name: 'unlink'},
                    null,
                    {
                        name: 'insertImage',
                        placeholder: 'Custom PlaceHolder Text',
                        button_class: 'btn-inverse',
                        //choose_file:false,//hide choose file button
                        button_text: 'Set choose_file:false to hide this',
                        button_insert_class: 'btn-pink',
                        button_insert: 'Insert Image'
                    },
                    null,
                    {
                        name: 'foreColor',
                        title: 'Custom Colors',
                        values: ['red', 'green', 'blue', 'navy', 'orange']
                        /**
                         You change colors as well
                         */
                    },
                /**null,
                 {
                           name:'backColor'
                       },*/
                    null,
                    {name: 'undo'},
                    {name: 'redo'},
                    null,
                    'viewSource'
                ],
                //speech_button:false,//hide speech button on chrome

                'wysiwyg': {
                    hotKeys: {} //disable hotkeys
                }

            }).prev().addClass('wysiwyg-style2');


            //handle form onsubmit event to send the wysiwyg's content to server



        }
    });


</script>
